const app = getApp();
var util = require('../../utils/util.js');
Page({
  data: {
    modal: {
      toastHidden: true,
      msg: ""
    },
    currentTab: 0, //预设当前项的值
    winWidth: 0,// 页面配置 
    winHeight: 0,
    tab: [
      { title: "一级", content: "11111111111" },
      { title: "二级", content: "3333333333" }
    ],
    oneFriends: [
      {
        tel: "15157135186",
        date: "2017-12-28",
        num: "3人",
        coupon: "￥300.00"
      }],
    twoFriends: [
      {
        tel: "15157135186",
        date: "2017-12-28",
        num: "3人",
        coupon: "￥300.00"
      }],
    pageNum: 1,
    pageSize: 10
  },
  onLoad: function (options) {
    var that = this;
    /* 获取系统信息 */
    wx.getSystemInfo({
      success: function (res) {
        console.log(res);
        that.setData({
          winWidth: res.windowWidth,
          winHeight: res.windowHeight
        });
      }
    });


    var data = {
      user: app.globalData.userUuid,
      pageNum: that.data.pageNum,
      pageSize: that.data.pageSize
    };
    // util.requestGet("coreUser/find/by/one", data, function (res) {
    //   if (res.success) {
    //     console.log(res)
    //     var new_content = [];
    //     var obj = {};
    //     for (var i = 0; i < res.data.result.length; i++) {
    //       var obj = {};
    //       obj.money = res.data.result[i].crcpnReduce;
    //       obj.date = new Date(res.data.result[i].crcpnStart).toLocaleDateString().substr(5) + "~" + new Date(res.data.result[i].crcpnEnd).toLocaleDateString().substr(5);
    //       new_content.push(obj);
    //     }
    //     that.setData({ "discontent": new_content });
    //   }
    // }, function (errData) {
    //   that.setData({ "modal.toastHidden": false, "modal.msg": '当前网格异常，请稍后再试' });
    // });
  },
  onShow: function () {
  },

  // 滑动切换tab 
  bindChange: function (e) {
    var that = this;
    that.setData({ currentTab: e.detail.current });

  },
  switchTab(e) {
    // console.log(e)
    // data - current与e.currentTarget.dataset.current是一一对应的值
    var that = this;
    var cur = e.currentTarget.dataset.current;
    that.setData({ currentTab: cur });
  },
  toastChange() {
    this.setData({ "modal.toastHidden": true });
  },
})